import { getMvAddressInfo } from "@/Api/publicMethods";
import { Message } from "element-ui";

const state = {
  videoSrc: "", //视频路径
  posterUrl: "", //视频封面路径
};

const mutations = {
  SET_VIDEO_URL: (state, url) => {
    state.videoSrc = url;
  },
  SET_POSTER_URL: (state, url) => {
    state.posterUrl = url;
  },
};

const actions = {
  Set_Video_Url({ commit }, uid) {
    return new Promise((resolve, reject) => {
      getMvAddressInfo({"id":uid,"r":1080})
        .then((res) => {
          // console.log("MV地址", res);
          if (res.code == 200) {
            commit("SET_VIDEO_URL", res.data.url);
            resolve();
          }
        })
        .catch((err) => {});
    }).catch((err) => {
    //   console.log(err);
      reject(err);
    });
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
